import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    component: () => import('../views/home/Index.vue')
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('../views/home/Home.vue')
  },
  {
    path: '/article/detail/:id',
    name: 'Detail',
    component: () => import('../views/article/Detail.vue')
  },
  {
    path: '/article/edit/:id?',
    name: 'Edit',
    component: () => import('../views/article/Edit.vue')
  },
  
  {
    path: '/test',
    name: 'Test',
    component: () => import('../views/test/Test.vue')
  },
  {
    path: '*',
    redirect: '/home'
  }
]
const router = new VueRouter({
  // 本地使用 hash 刷新不会丢失 方便开发
  // 上线去掉 # 号 刷新不丢失给服务器做处理
  mode: process.env.NODE_ENV === 'development' ? 'hash' : 'history',
  base: process.env.VUE_APP_BASE_URL,
  routes
})

export default router
